<template>
	<div class="user-avatar-dropdown">
		<Dropdown @on-click="handleClick">
			<Avatar :src="userAvatar" />
			<Icon :size="18" type="md-arrow-dropdown"></Icon>
			<DropdownMenu slot="list">
				<!-- <DropdownItem name="message">
          消息中心<Badge style="margin-left: 10px" :count="messageUnreadCount"></Badge>
        </DropdownItem> -->
				<DropdownItem name="logout">退出登录</DropdownItem>
			</DropdownMenu>
		</Dropdown>
	</div>
</template>

<script>
import { setToken, mgr } from '@/libs/util'
import './user.less'
import { mapActions } from 'vuex'
export default {
	name: 'User',
	props: {
		userAvatar: {
			type: String,
			default: ''
		}
	},
	methods: {
		...mapActions(['handleLogOut']),
		logout() {
			this.$Modal.confirm({
				title: '提示',
				content: '是否确认退出？',
				onOk: () => {
					setToken(null)
					mgr.signoutRedirect()
				}
			})
		},
		handleClick(name) {
			switch (name) {
				case 'logout':
					this.logout()
					break
			}
		}
	}
}
</script>
